package com.sky.mapper;

import com.sky.dto.BlogDTO;
import com.sky.entity.Blog;
import com.sky.entity.ManageBlog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ManageBlogMapper {

    /**
     * 增加管理端博客数据库
     * @param manageBlog
     */
    @Insert("insert into game_forum.t_post (post_id, title, content, post_type, category, user_id,  is_top, image_urls,  tags, create_time, update_time) " +
            "VALUES(#{postId},#{title},#{content},#{category},#{category},#{userId},#{isTop},#{imageUrls},#{tags},#{createTime},#{updateTime}) ")
    void insert(ManageBlog manageBlog);

    /**
     * 增加浏览量
     * @param id
     */
    @Update("update game_forum.t_post set view_count = view_count+1 where post_id=#{id}")
    void addPageView(String id);



    @Update("update game_forum.t_post set like_count =like_count-1 where post_id=#{postId}")
    void deleteLike(ManageBlog manageBlog);

    @Update("update game_forum.t_post set like_count =like_count-1 where post_id=#{postId}")
    void addLikeCount(ManageBlog manageBlog);


    @Update("update game_forum.t_post set comment_count =comment_count-1 where post_id=#{Id}")
    void addCommentCount(String id);
}
